#include <iostream>
using namespace std;
#define MAX_N 1000
int height[MAX_N + 5];
int dp[MAX_N + 5];
int contray_dp[MAX_N + 5];

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> height[i];
    }
    height[0] = 0;
    dp[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j < i; j++)
        {
            if(height[j] < height[i]) dp[i] = max(dp[i], dp[j] + 1);
        }
        // cout << "dp[" << i <<"]: " << dp[i] << " ";
    }
    // cout << endl;
    height[n + 1] = 0;
    contray_dp[n + 1] = 0;
    for(int i = n; i >= 1; i--)
    {
        for(int j = n + 1; j > i; j--)
        {
            if(height[j] < height[i]) contray_dp[i] = max(contray_dp[i], contray_dp[j] + 1);
        }
        // cout << "contray_dp[" << i <<"]: " << contray_dp[i] << " ";
    }
    // cout << endl;
    int ret = 0;
    for(int i = 1; i <= n; i++)
    {
        // std::cout << "dp: " << dp[i] << " contrary_dp: " << contray_dp[i] <<endl;
        ret = max(dp[i] + contray_dp[i], ret);
    }
    cout << n - ret + 1;
    return 0;
}